package com.hmall.search.pojo;
import com.hmall.common.pojo.item.Item;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ItemDoc implements Serializable {
    /**
     * 订单id
     */
    private Long id;
    /**
     * 商品名字
     */
    private String name;
    /**
     * 商品价格
     */
    private Long price;
    /**
     * 商品图片
     */
    private  String image;
    /**
     * 商品分类
     */
    private String category;
    /**
     * 商品品牌
     */
    private String brand;
    /**
     * 商品销售量
     */
    private Integer sold;
    /**
     * 商品评论数
     */
    private Integer commentCount;

    private Boolean isAD;

    private List<String> suggestion = new ArrayList<>(2);

    public ItemDoc(Item item){
        this.id = item.getId();
        this.name = item.getName();
        this.price = item.getPrice();
        this.image = item.getImage();
        this.category = item.getCategory();
        this.brand = item.getBrand();
        this.sold = item.getSold();
        this.commentCount= item.getCommentCount();
        if(item.getIsAd()==0){
            this.isAD=false;
        }else {
            this.isAD = true;
        }

        //2.补全
        suggestion.add(item.getBrand());
        suggestion.add(item.getCategory());
    }
}
